{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 第五次练习"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "+ 请务必交到exer5文件夹下，**谢绝交到master下**\n",
    "+ 请不要改动任何文件，拜托\n",
    "+ 请在11月7日前提交。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "请写一下姓名和学号：\n",
    "+ 姓名  \n",
    "+ 学号"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目一、贫困户模型\n",
    "+ 创建一个类，包含贫困户的义务教育保障、住房安全、饮水安全、肉蛋奶豆的四个属性\n",
    "+ 包含一个是否贫困的预测，如果四个属性有两个以上没有保障（>2)则输出为贫困户\n",
    "+ 对贫困户，采取相应措施（输入参数）对其进行帮扶，使其脱贫\n",
    "+ 至少生成三个实例\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目二: 学生信息\n",
    "+ 创建一个类，包含姓名、分数、睡眠时间三个属性\n",
    "+ 包含一个胖瘦的预测，如果分数>90，且睡眠时间少于6小时，输出“BMI可能偏大”，否则输出“体重正常”\n",
    "+ 为使得标准（90分、6小时）可以调整，标准应设为输入的参数\n",
    "+ 至少生成三个实例"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目三：“跑步社”成员类\n",
    "+ 创建一个“跑步社”成员类，以学生信息类为父类\n",
    "+ 添加一个属性为跑步\n",
    "+ 如果跑步时间大于30分钟，如果之前预测为“BMI可能偏大”，则输出为“趋向正常”\n",
    "+ 至少生成三个实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "该用户贫困,应采取措施\n",
      "请对义务教育进行保障\n",
      "请对饮水安全进行保障\n",
      "请对肉蛋奶豆进行保障\n",
      "\n",
      "\n",
      "该用户不贫困\n",
      "\n",
      "\n",
      "该用户贫困,应采取措施\n",
      "请对饮水安全进行保障\n",
      "请对肉蛋奶豆进行保障\n"
     ]
    }
   ],
   "source": [
    "class asset_degree(object):\n",
    "    def __init__(self,x1,x2,x3,x4): \n",
    "        self.com_edu = x1\n",
    "        self.buid_safe = x2\n",
    "        self.war_safe = x3\n",
    "        self.food = x4\n",
    "        \n",
    "    def education(self,years):\n",
    "        self.com_edu = 0\n",
    "        if years >= 9 :\n",
    "            self.com_edu = 1\n",
    "        else :\n",
    "            self.com_edu = 0\n",
    "            \n",
    "            \n",
    "    def building(self,time):\n",
    "        self.buid_safe = 0\n",
    "        if time > 10:\n",
    "            self.buid_safe = 0\n",
    "        else :\n",
    "            self.buid_safe = 1\n",
    "            \n",
    "            \n",
    "    def warter(self,disinfection):\n",
    "        self.war_safe = 0\n",
    "        if disinfecton == 'yes':\n",
    "            self.war_safe = 1\n",
    "        else:\n",
    "            self.war_safe = 0\n",
    "            \n",
    "    def toss_level(self):\n",
    "        sum = self.com_edu + self.buid_safe + self.war_safe + self.food\n",
    "        if sum >2:\n",
    "            print('该用户不贫困')\n",
    "             \n",
    "        else:\n",
    "            print('该用户贫困,应采取措施')\n",
    "            \n",
    "            if  self.com_edu == 0:\n",
    "                print('请对义务教育进行保障')\n",
    "            if self.buid_safe == 0:\n",
    "                print('请对住房安全进行保障')\n",
    "            if self.war_safe == 0:\n",
    "                print('请对饮水安全进行保障')\n",
    "            if self.food == 0:\n",
    "                print('请对肉蛋奶豆进行保障')\n",
    "amprt = asset_degree(0,1,0,0)\n",
    "amprt.toss_level() \n",
    "print('\\n')\n",
    "\n",
    "amprt_1 = asset_degree(0,1,1,1)\n",
    "amprt_1.toss_level()\n",
    "print('\\n')\n",
    "\n",
    "amprt_2 = asset_degree(1,1,0,0)\n",
    "amprt_2.toss_level()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "体重正常\n",
      "体重正常\n",
      "BMI可能偏大\n"
     ]
    }
   ],
   "source": [
    "class Student(object):\n",
    " \n",
    "  def __init__(self, name, score,sleep_time):\n",
    "    self.name = name\n",
    "    self.score = score\n",
    "    self.sleep_time = sleep_time\n",
    "  \n",
    "  def predic_shape(self,c1,c2):\n",
    "    if self.score >= c1 and self.sleep_time <= c2:\n",
    "        return 'BMI可能偏大'\n",
    "    else:\n",
    "        return '体重正常'\n",
    "stu = Student('xiaoming',85,7)\n",
    "print(stu.predic_shape(90,6))\n",
    "mxs = Student('xiaoli',85,12)\n",
    "print(mxs.predic_shape(90,6))\n",
    "wer = Student('xiaozhang',95,7)\n",
    "print(wer.predic_shape(85,8))\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "体重正常\n",
      "BMI可能偏大\n",
      "体重正常\n"
     ]
    }
   ],
   "source": [
    "class Student(object):\n",
    " \n",
    "  def __init__(self, name, score,sleep_time):\n",
    "    self.name = name\n",
    "    self.score = score\n",
    "    self.sleep_time = sleep_time\n",
    "  \n",
    "  def predic_shape(self,c1,c2):\n",
    "    if self.score >= c1 and self.sleep_time <= c2:\n",
    "        return 'BMI可能偏大'\n",
    "    else:\n",
    "        return '体重正常'\n",
    "\n",
    "class run_luster(Student):\n",
    "    def __init__(self, name, score,sleep_time,run_time):\n",
    "        super().__init__(name,score,sleep_time)                      \n",
    "        self.run_time = run_time\n",
    "    def predic_shape(self,c1,c2):\n",
    "        if self.score >= c1 and self.sleep_time <= c2:\n",
    "            if self.run_time >=30:\n",
    "                return '体重正常'\n",
    "            return 'BMI可能偏大'\n",
    "        else:\n",
    "            return '体重正常'\n",
    "meeen = run_luster('xiaowang',95,5,60)\n",
    "print(meeen.predic_shape(90,6))\n",
    "stu = run_luster('xiaoming',95,4,12)\n",
    "print(stu.predic_shape(90,6))\n",
    "mxs = run_luster('xiaoli',85,4,34)\n",
    "print(mxs.predic_shape(90,6))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
